import yhfx from '{platform}/script/views/tjzx/yhfx/index';
import {tbody,tleftCheck,tcount} from '{platform}/script/views/table/tableData'
import tableObj from '{platform}/script/pages/table/index';
import search from '{platform}/script/pages/search/index';
var template=require('template');
var events=require('events');
var request = require('{pub}/request');
var func = require('{pub}/function');
var message = require('{layer}/message');
return {
    target:'#yhfx',
    path:'/yhfx/',
    template:yhfx, 
    tbHead:{
        leftType:'',
        bottomCount:false,
        nopage:true,
        headArr:[{
            name:'监控点',type:'jkd',width:100
        },{
            name:'当日数据',type:'todaysum',width:100
        },{
            name:'过去七天累计数据',type:'lastmonthsum',width:150
        },{
            name:'本月累计数据',type:'monthsum',width:150
        },{
            name:'上月累计数据',type:'weeksum',width:150
        },{
            name:'累计数据',type:'allsum',width:100
        }]
    },
    events:{
        "":"",
    },
    onInit:function(){
        var _that =  this;
        tableObj.init(_that.element.find('.g-table-view'),{tabHead:this.tbHead},{_that:this,url:'/tjzx/yhfx/list',param:{query:'y'},callback:this.reqYhfx})
    },

    reqYhfx:function(res) {
        var that = this._that;
        if(res.result === 'success') {
            var rows = res.data;
            that.tableData(rows)
        } else {
            message('error', res.message)
        }
        
    },
    tableData:function(data) {
        var _that = this,tbHead = _that.tbHead.headArr;
            var i,len = data.length, j, jlen = tbHead.length, tbBody = [];
            for(i=0;i<len;i++) {
                tbBody.push({
                    id:data[i].id || '',
                    td:[],
                });
                for(j =0;j<jlen;j++) {
                    tbBody[i].td.push({
                        name:data[i][tbHead[j].type] || '',
                        type:tbHead[j].type
                    });
                }
            }
            $('#tableData').html(template.render(tbody, {tabBody:tbBody}));
    }
}